-
Notifications
You must be signed in to change notification settings - Fork 260
chore(auth): legacy credential provider to use AuthOutputs instead of AmplifyConfig types #5303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… AmplifyConfig types
ecd7a0c
to
90a7f7e
Compare
String username, | ||
AuthOutputs authOutputs, | ||
) async { | ||
if (authOutputs.userPoolClientId == null) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Remove the force casts. If you create variables for userPoolId and userPoolClientId and return early if they are null, then Dart will not require the force case.
final userPoolId = authOutputs.userPoolId;
final userPoolClientId = authOutputs.userPoolClientId;
if (userPoolId == null || userPoolClientId == null) return null;
final userPoolStorage = await _getUserPoolStorage();
final cognitoUserKeys = LegacyCognitoUserKeys(userPoolClientId);
final currentUserId = await userPoolStorage.read(
key: cognitoUserKeys[LegacyCognitoKey.currentUser],
);
if (currentUserId == null) return null;
final keys = LegacyDeviceSecretKeys(currentUserId, userPoolId);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This applies to several other locations in the PR.
if (currentUserId == null) return; | ||
final keys = LegacyDeviceSecretKeys(currentUserId, userPoolConfig); | ||
final asfKeys = LegacyAsfDeviceKeys(currentUserId, userPoolConfig); | ||
if (currentUserId == null || authOutputs.userPoolId == null) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same suggestion as above. Remove the force cast by creating a userPoolId var.
final currentUser = await userPoolStorage.read( | ||
key: cognitoUserKeys[LegacyCognitoKey.currentUser], | ||
); | ||
if (currentUser != null) { | ||
final userPoolKeys = LegacyCognitoUserPoolKeys( | ||
currentUser, | ||
userPoolConfig, | ||
authOutputs.userPoolClientId!, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See suggestion below about remove force casts
a09c772
to
de14ec5
Compare
de14ec5
to
1ea7f5f
Compare
… AmplifyConfig types (#5303)
… AmplifyConfig types (#5303)
… AmplifyConfig types (#5303)
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.